package base;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class ObjectOrPropertyDemo {

    public static void main(String[] args) {
        User user = new User("A", 11);
        log.info("user=" + user);
        user = changeObject(user);
        log.info("user={}", user);
        changeProperty(user);
        log.info("user={}", user);

        ObjectOrPropertyDemo demo = new ObjectOrPropertyDemo();
        demo.superOrThis();
    }

    public static User changeObject(User user) {
        user = new User("B", 12);
        return user;
    }

    public static void changeProperty(User user) {
        user.setName("C");
        user.setAge(13);
    }

    @Override
    public String toString() {
        return "ObjectOrPropertyDemo{}";
    }

    @Override
    public int hashCode() {
        return super.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        return super.equals(obj);
    }

    public void superOrThis() {
        log.info("super.toString()={}", super.toString());
        log.info("this.toString()={}", this.toString());
    }
}


